﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Lk.WebTow.Data
{

    /// <summary>
    /// add-migration-init
    /// </summary>
    public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
    {
        //ApplicationDbContext 代表的是你的创建失败的那个类型
        public ApplicationDbContext CreateDbContext(string[] args)
        {
            IConfigurationRoot configuration = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json")
            .Build();
            var builder = new DbContextOptionsBuilder();

            //Server=.;Database=IdentityDemo;Trusted_Connection=True;MultipleActiveResultSets=true;uid=sa;pwd=111
            builder.UseSqlServer("Server=.;Database=WebTow;Trusted_Connection=True;MultipleActiveResultSets=true;uid=sa;pwd=111");
            return new ApplicationDbContext(builder.Options);
        }

    }
}
